package storageclasses;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Scanner;

public class ReadFile {

	String filename;
	public ReadFile(String filename){
		this.filename = filename;
	}
	
	public String[][] readFile(){
		File fin;
		String[][] matrix = null;
		try {
			fin = new File(filename);
			
			Scanner scan = new Scanner(fin);
			int i = 0;
			while (scan.hasNext()) {
				if( scan.nextLine() == ""){
					break;
				}
				i++;

			}

			scan = new Scanner(fin);
			matrix = new String[i][4];
			
			for (int j = 0; j < i; j++) {
				String line = scan.nextLine();
				String[] split = line.split(",");
				
				for (int k = 0; k < 4; k++) {
					matrix[j][k] = split[k];
				}
				
					
			}
			
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} 
		return matrix;
	}

}
